package net;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class MessageRouter {
	public static Map<String, IMessageHandler> handlers = new ConcurrentHashMap<String, IMessageHandler>();
	
	public static void register(String msg, IMessageHandler handler) {
		handlers.put(msg, handler);
	}
	
	public static boolean route(String msg, Client client) throws Exception {
		IMessageHandler handler = handlers.get(msg);
		if (handler == null) return false;
		return handler.handle(client);
	}
}
